package cn.itcast.demo;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

@WebServlet("/ServletDemo04")
public class ServletDemo04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//          缓存
        String str = "这是一个缓存语句。";
//        设置缓存时间
        resp.setDateHeader("Expires",System.currentTimeMillis() + 1*60*60*1000);
//        设置编码格式
        resp.setContentType("text/html;charset=UTF-8");
//        写出数据
        resp.getWriter().write(str);
        System.out.println("aaa");


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
